<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

add_theme_support('menus');
add_theme_support('post-thumbnails');

/* * *********************************************************
 * 
 */
if (function_exists('wp_nav_menu')) {

    function wp_my_menus() {
        //đăng ký menu cho theme
        register_nav_menus(array(
            'primary-menu' => __('Menu Chính'),
            'secondary-menu' => __('Menu Phụ'),
                )
        );
    }

    //theme vào cấu hình mặc định
    add_action('init', 'wp_my_menus');
}

function get_thumb_img($post_id, $h, $w, $q, $zc, $alt) {
    echo '<img align="middle" src="';
    echo bloginfo('template_url');
    echo '/timthumb.php?src=' . get_featured_img($post_id) . '&amp;h=' . $h . '&amp;w=' . $w . '&amp;q=' . $q . '&amp;zc=' . $zc . '" alt="' . $alt . '" />';
}
if (function_exists('register_sidebar')) {
    register_sidebar(
            array(
                'name' => 'Leftsidebar',
                'before_title' => '<h3>',
                'after_title' => '</h3>',
                'before_widget' => "<div class='boxes'>",
                'after_widget' => '</div>',
            )
    );
}
if (function_exists('register_sidebar')) {
    register_sidebar(
            array(
                'name' => 'yahoosidebar',
                'before_title' => '<h3>',
                'after_title' => '</h3>',
                'before_widget' => "<div class='boxes'>",
                'after_widget' => '</div>',
            )
    );
}
add_filter('images_cpt', 'my_image_cpt');

function my_image_cpt() {
    $cpts = array('product');
    return $cpts;
}



function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if ($count == '') {
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '1');
    } else {
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
function short_content($num_words) {
    $get_the_content = get_the_content();
    $striptag_from_content = strip_tags($get_the_content);
    echo $content = wp_trim_words($striptag_from_content, $num_words = $num_words, $more = null);
}
?>
